<template>
	<!-- 商品卡片，可用于购买、订单部分展示 -->
	<view class="order-body">
		<view class="product-section">
			<view class="product-image-container">
				<image :src="path + getImgUrl" mode="aspectFill"></image>
				<!-- <image src="/static/main/cs3.jpg" mode="aspectFill"></image> -->
			</view>

			<view class="product-details">
				<view class="product-title">{{ goodName }}</view>
				<view class="rate-image">
					<u-rate :value="goodStars" disabled></u-rate>
					<view class="rxsp-image" v-if="order != '' && order.goodType == 1">
						<image src="/static/main/rxsp.png"></image>
					</view>
					<view class="jtsp-image" v-if="order != '' && order.goodType == 2">
						<image src="/static/main/jtsp.png"></image>
					</view>
				</view>

				<view class="quantity">数量：x{{ totalNum }}</view>
				<view class="right-bottom">
					单价：
					<text>
						<span>￥</span>
						{{ todayPrice }}
					</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import api from '@/api/index.js';
export default {
	name: 'x-goods-card',
	props: {
		order: {
			type: Object,
			default: ''
		},
		totalNum: {
			type: [String, Number],
			default: '0'
		},
		getImgUrl: {
			type: String,
			default: ''
		},
		goodName: {
			type: String,
			default: ''
		},
		goodStars: {
			type: [String, Number],
			default: '0'
		},
		todayPrice: {
			type: [String, Number],
			default: 0
		}
	},
	data() {
		return {
			path: api.getPath()
		};
	}
};
</script>

<style lang="scss" scoped>
.order-body {
	padding: 20rpx 30rpx;
	background-color: #fff;
	border-radius: 30rpx;

	.product-section {
		display: flex;
		border-bottom: 1px dashed #f0f0f0;
		border-radius: 4px;
		overflow: hidden;

		.product-image-container {
			image {
				width: 260rpx;
				height: 210rpx;
				border-radius: 20rpx;
			}
		}

		.product-details {
			flex: 1;
			padding-left: 16px;
			display: flex;
			flex-direction: column;
			justify-content: space-evenly;

			.right-bottom {
				display: flex;
				align-items: center;
				text {
					font-family: MiSans, MiSans;
					font-weight: 500;
					font-size: 30rpx;
					color: #f05a39;
					text-align: center;
					font-style: normal;
					text-transform: none;
					span {
						font-size: 23rpx;
					}
				}
			}
			.product-title {
				font-weight: 550;
				font-size: 28rpx;
				color: #000000;
				display: -webkit-box;
				-webkit-line-clamp: 1; /* 限制为两行 */
				-webkit-box-orient: vertical;
				overflow: hidden;
				text-overflow: ellipsis;
			}
			.rate-image {
				display: flex;
				justify-content: space-between;
				align-items: center;
			}

			.quantity {
				font-size: 14px;
				color: #666;
				margin-bottom: 10px;
			}
		}
	}
}
</style>
